<template lang="pug">
    div
        h1 曝光管理
        el-table(:data="data.data")
            el-table-column(prop="title",   label="标题")
            el-table-column(prop="content",     label="曝光内容")
            el-table-column(label="相关图片")
                template(slot-scope="scope")
                    img(:src="scope.row.img_url_arr")
            el-table-column(prop="wx",     label="微信号")
            el-table-column(prop="tag",     label="标签")
            el-table-column(label="状态")
                template(slot-scope="scope") {{scope.row.type === 1 ? '通过' : '不通过'}}
            el-table-column(prop="create_time",     label="创建时间")
            el-table-column(prop="update_time",     label="更新时间")
            el-table-column(prop="create_user",     label="创建用户名")
            el-table-column(prop="update_user",     label="更新用户名")
            el-table-column(prop="audit_time",     label="审核时间")
            el-table-column(label="操作")
                template(slot-scope="scope")
                    Button.button(type="info",      @click="update(scope.row.exposure_id, 1)") 通过
                    Button.button(type="default",   @click="update(scope.row.exposure_id, -1)") 不通过
        Page(:total="data.total_count", @on-change="index")
</template>

<script>
    export default {
        data() {
            return {
                page: 1,
                data: {
                    data: [],
                    total_count: 0,
                }
            }
        },

        methods: {
            async index(page = 1) {
                this.data = await this.$http.post('tools_exposure/getExposureList', {page_index: page - 1, page_size: 20});
                this.page = page;
            },

            async update(exposure_id, state) {
                try {
                    await this.$confirm(`确认 ${state === 1 ? '通过' : '不通过'}该举报？`, '举报处理确认');
                    await this.$http.post('tools_report/setExposureList', {exposure_id, state});
                    this.index();
                } catch (e) {}
            }
        },
        created() {
            this.index();
        }
    }
</script>
